/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package REABR.impl;

import REA.REAAttribute;
import REA.REAPolicyEntity;
import REA.REAPolicyRelation;

import REABR.AttributeValidationPolicy;
import REABR.Operator;
import REABR.REABRPackage;

import org.eclipse.emf.common.notify.Notification;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Attribute Validation Policy</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link REABR.impl.AttributeValidationPolicyImpl#getPolicyAttribute <em>Policy Attribute</em>}</li>
 *   <li>{@link REABR.impl.AttributeValidationPolicyImpl#getOperationalAttribute <em>Operational Attribute</em>}</li>
 *   <li>{@link REABR.impl.AttributeValidationPolicyImpl#getOperator <em>Operator</em>}</li>
 *   <li>{@link REABR.impl.AttributeValidationPolicyImpl#getPolicyEntity <em>Policy Entity</em>}</li>
 *   <li>{@link REABR.impl.AttributeValidationPolicyImpl#getPolicyRelationship <em>Policy Relationship</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class AttributeValidationPolicyImpl extends PolicyImpl implements AttributeValidationPolicy {
	/**
	 * The cached value of the '{@link #getPolicyAttribute() <em>Policy Attribute</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getPolicyAttribute()
	 * @generated
	 * @ordered
	 */
	protected REAAttribute policyAttribute;

	/**
	 * The cached value of the '{@link #getOperationalAttribute() <em>Operational Attribute</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getOperationalAttribute()
	 * @generated
	 * @ordered
	 */
	protected REAAttribute operationalAttribute;

	/**
	 * The default value of the '{@link #getOperator() <em>Operator</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getOperator()
	 * @generated
	 * @ordered
	 */
	protected static final Operator OPERATOR_EDEFAULT = Operator.EQUALS;

	/**
	 * The cached value of the '{@link #getOperator() <em>Operator</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getOperator()
	 * @generated
	 * @ordered
	 */
	protected Operator operator = OPERATOR_EDEFAULT;

	/**
	 * The cached value of the '{@link #getPolicyEntity() <em>Policy Entity</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getPolicyEntity()
	 * @generated
	 * @ordered
	 */
	protected REAPolicyEntity policyEntity;

	/**
	 * The cached value of the '{@link #getPolicyRelationship() <em>Policy Relationship</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getPolicyRelationship()
	 * @generated
	 * @ordered
	 */
	protected REAPolicyRelation policyRelationship;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected AttributeValidationPolicyImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return REABRPackage.Literals.ATTRIBUTE_VALIDATION_POLICY;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public REAAttribute getPolicyAttribute() {
		if (policyAttribute != null && policyAttribute.eIsProxy()) {
			InternalEObject oldPolicyAttribute = (InternalEObject)policyAttribute;
			policyAttribute = (REAAttribute)eResolveProxy(oldPolicyAttribute);
			if (policyAttribute != oldPolicyAttribute) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, REABRPackage.ATTRIBUTE_VALIDATION_POLICY__POLICY_ATTRIBUTE, oldPolicyAttribute, policyAttribute));
			}
		}
		return policyAttribute;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public REAAttribute basicGetPolicyAttribute() {
		return policyAttribute;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setPolicyAttribute(REAAttribute newPolicyAttribute) {
		REAAttribute oldPolicyAttribute = policyAttribute;
		policyAttribute = newPolicyAttribute;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, REABRPackage.ATTRIBUTE_VALIDATION_POLICY__POLICY_ATTRIBUTE, oldPolicyAttribute, policyAttribute));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public REAAttribute getOperationalAttribute() {
		if (operationalAttribute != null && operationalAttribute.eIsProxy()) {
			InternalEObject oldOperationalAttribute = (InternalEObject)operationalAttribute;
			operationalAttribute = (REAAttribute)eResolveProxy(oldOperationalAttribute);
			if (operationalAttribute != oldOperationalAttribute) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, REABRPackage.ATTRIBUTE_VALIDATION_POLICY__OPERATIONAL_ATTRIBUTE, oldOperationalAttribute, operationalAttribute));
			}
		}
		return operationalAttribute;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public REAAttribute basicGetOperationalAttribute() {
		return operationalAttribute;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setOperationalAttribute(REAAttribute newOperationalAttribute) {
		REAAttribute oldOperationalAttribute = operationalAttribute;
		operationalAttribute = newOperationalAttribute;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, REABRPackage.ATTRIBUTE_VALIDATION_POLICY__OPERATIONAL_ATTRIBUTE, oldOperationalAttribute, operationalAttribute));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Operator getOperator() {
		return operator;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setOperator(Operator newOperator) {
		Operator oldOperator = operator;
		operator = newOperator == null ? OPERATOR_EDEFAULT : newOperator;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, REABRPackage.ATTRIBUTE_VALIDATION_POLICY__OPERATOR, oldOperator, operator));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public REAPolicyEntity getPolicyEntity() {
		if (policyEntity != null && policyEntity.eIsProxy()) {
			InternalEObject oldPolicyEntity = (InternalEObject)policyEntity;
			policyEntity = (REAPolicyEntity)eResolveProxy(oldPolicyEntity);
			if (policyEntity != oldPolicyEntity) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, REABRPackage.ATTRIBUTE_VALIDATION_POLICY__POLICY_ENTITY, oldPolicyEntity, policyEntity));
			}
		}
		return policyEntity;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public REAPolicyEntity basicGetPolicyEntity() {
		return policyEntity;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setPolicyEntity(REAPolicyEntity newPolicyEntity) {
		REAPolicyEntity oldPolicyEntity = policyEntity;
		policyEntity = newPolicyEntity;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, REABRPackage.ATTRIBUTE_VALIDATION_POLICY__POLICY_ENTITY, oldPolicyEntity, policyEntity));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public REAPolicyRelation getPolicyRelationship() {
		if (policyRelationship != null && policyRelationship.eIsProxy()) {
			InternalEObject oldPolicyRelationship = (InternalEObject)policyRelationship;
			policyRelationship = (REAPolicyRelation)eResolveProxy(oldPolicyRelationship);
			if (policyRelationship != oldPolicyRelationship) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, REABRPackage.ATTRIBUTE_VALIDATION_POLICY__POLICY_RELATIONSHIP, oldPolicyRelationship, policyRelationship));
			}
		}
		return policyRelationship;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public REAPolicyRelation basicGetPolicyRelationship() {
		return policyRelationship;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setPolicyRelationship(REAPolicyRelation newPolicyRelationship) {
		REAPolicyRelation oldPolicyRelationship = policyRelationship;
		policyRelationship = newPolicyRelationship;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, REABRPackage.ATTRIBUTE_VALIDATION_POLICY__POLICY_RELATIONSHIP, oldPolicyRelationship, policyRelationship));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case REABRPackage.ATTRIBUTE_VALIDATION_POLICY__POLICY_ATTRIBUTE:
				if (resolve) return getPolicyAttribute();
				return basicGetPolicyAttribute();
			case REABRPackage.ATTRIBUTE_VALIDATION_POLICY__OPERATIONAL_ATTRIBUTE:
				if (resolve) return getOperationalAttribute();
				return basicGetOperationalAttribute();
			case REABRPackage.ATTRIBUTE_VALIDATION_POLICY__OPERATOR:
				return getOperator();
			case REABRPackage.ATTRIBUTE_VALIDATION_POLICY__POLICY_ENTITY:
				if (resolve) return getPolicyEntity();
				return basicGetPolicyEntity();
			case REABRPackage.ATTRIBUTE_VALIDATION_POLICY__POLICY_RELATIONSHIP:
				if (resolve) return getPolicyRelationship();
				return basicGetPolicyRelationship();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case REABRPackage.ATTRIBUTE_VALIDATION_POLICY__POLICY_ATTRIBUTE:
				setPolicyAttribute((REAAttribute)newValue);
				return;
			case REABRPackage.ATTRIBUTE_VALIDATION_POLICY__OPERATIONAL_ATTRIBUTE:
				setOperationalAttribute((REAAttribute)newValue);
				return;
			case REABRPackage.ATTRIBUTE_VALIDATION_POLICY__OPERATOR:
				setOperator((Operator)newValue);
				return;
			case REABRPackage.ATTRIBUTE_VALIDATION_POLICY__POLICY_ENTITY:
				setPolicyEntity((REAPolicyEntity)newValue);
				return;
			case REABRPackage.ATTRIBUTE_VALIDATION_POLICY__POLICY_RELATIONSHIP:
				setPolicyRelationship((REAPolicyRelation)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case REABRPackage.ATTRIBUTE_VALIDATION_POLICY__POLICY_ATTRIBUTE:
				setPolicyAttribute((REAAttribute)null);
				return;
			case REABRPackage.ATTRIBUTE_VALIDATION_POLICY__OPERATIONAL_ATTRIBUTE:
				setOperationalAttribute((REAAttribute)null);
				return;
			case REABRPackage.ATTRIBUTE_VALIDATION_POLICY__OPERATOR:
				setOperator(OPERATOR_EDEFAULT);
				return;
			case REABRPackage.ATTRIBUTE_VALIDATION_POLICY__POLICY_ENTITY:
				setPolicyEntity((REAPolicyEntity)null);
				return;
			case REABRPackage.ATTRIBUTE_VALIDATION_POLICY__POLICY_RELATIONSHIP:
				setPolicyRelationship((REAPolicyRelation)null);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case REABRPackage.ATTRIBUTE_VALIDATION_POLICY__POLICY_ATTRIBUTE:
				return policyAttribute != null;
			case REABRPackage.ATTRIBUTE_VALIDATION_POLICY__OPERATIONAL_ATTRIBUTE:
				return operationalAttribute != null;
			case REABRPackage.ATTRIBUTE_VALIDATION_POLICY__OPERATOR:
				return operator != OPERATOR_EDEFAULT;
			case REABRPackage.ATTRIBUTE_VALIDATION_POLICY__POLICY_ENTITY:
				return policyEntity != null;
			case REABRPackage.ATTRIBUTE_VALIDATION_POLICY__POLICY_RELATIONSHIP:
				return policyRelationship != null;
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (operator: ");
		result.append(operator);
		result.append(')');
		return result.toString();
	}

} //AttributeValidationPolicyImpl
